package AcWing周赛;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: a
 * Date: 2022-10-01
 * Time: 19:06
 */
public class Demo71_2 {
    private static boolean isNum(long x){
        for(int i = 2; i <= Math.sqrt((double)x); i++){
            if(x % i == 0){
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        int res = 0;
        while(n > 0){
            if(n == 1 || n == 2){
                res++;
                break;
            }
            for(long i = n; i > 2; i--){
                if(isNum(i)){
                    res++;
                    n = n - i;
                    break;
                }
            }
        }
        System.out.println(res);
    }
}
